#include  <iostream>
using namespace std;

void swap(int *a, int *b)
{
	int temp = *a;
	*a = *b;
	*b = temp;
}

void isort(int *arr, int n)
{
	for( int i = 1 ; i < n ; ++i )
	{
		for( int j = i - 1; j >= 0 ; --j )
		{
			if( arr[j] > arr[j+1] )
				swap(&arr[j],&arr[j+1]);
			else
				break;
		}
	}
}

int main(int argc, char *argv[])
{
	int a[5] = {5,4,3,2,1};
	isort(a,5);

	for( int i = 0 ; i < 5 ; ++i )
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
